﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data;
using DevExpress.Utils;
using DevExpress.XtraGrid.Views.Grid;

namespace QuanLyKho.QuanLyChung
{
    public partial class HanhTrinh_Popup : Form
    {
        public static string SoChungTu = string.Empty;
        public HanhTrinh_Popup()
        {
            InitializeComponent();
            Loaddata();
            SetPropertiesGrid();
            SetPropertiesColumns();
        }

        public void Loaddata()
        {
            DataTable data = DataAll.SelectAll("HanhTrinh", "*", "Where SoChungTu ='" + SoChungTu + "'");
            gridHanhTrinh.DataSource = data;
        }

        public void SetPropertiesGrid()
        {
            //gvHanhTrinh.BestFitColumns();
            gvHanhTrinh.FocusRectStyle = DrawFocusRectStyle.RowFullFocus;
            gvHanhTrinh.OptionsBehavior.Editable = false;
            gvHanhTrinh.OptionsSelection.EnableAppearanceFocusedCell = true;
            gvHanhTrinh.OptionsSelection.MultiSelect = true;
            gvHanhTrinh.OptionsView.ShowGroupPanel = false;
            gvHanhTrinh.OptionsView.ColumnAutoWidth = true;
            gvHanhTrinh.OptionsView.ShowFooter = true;
            gvHanhTrinh.OptionsFind.AlwaysVisible = true;
            gvHanhTrinh.Columns["ID"].Visible = false;
        }

        public void SetPropertiesColumns()
        {
            gcTrangThai.Width = 200;
        }

        private void gvHanhTrinh_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            if (e.Column.FieldName == "TrangThai")
            {
                e.DisplayText = Common.HienThiTrangThai(Convert.ToInt32(e.Value));
            }
            if (e.Column.FieldName == "PhongBan")
            {
                e.DisplayText = Common.HienThiPhongBan(Convert.ToInt32(e.Value));
            }
            if (e.Column.FieldName == "NgayThang")
            {
                e.DisplayText = Convert.ToDateTime(e.Value).ToString("dd/MM/yyyy hh:mm:ss");
            }
        }
    }
}
